// 模拟购物车接口

export const getCartList = (param: any = {}, callback: Function) => {
    let {
        pageIndex,
        pageSize
    } = param
    pageIndex = pageIndex || 1
    pageSize = pageSize || 20
    let res: any = {
        data: {
            content: [],
            pageIndex: pageIndex,
            pageSize: pageSize,
        }
    }
    for (let i = 0; i < pageSize; i++) {
        res.data.content.push(getCartItem())
    }
    callback(res)
}

let getCartItem = () => {
    let id = Math.floor(Math.random() * 10000 + 10000)
    let price = Math.floor(Math.random() * 300 + 10)
    let data = mixData()
    return {
        id,
        name: `商品${id}`,
        desc: `Lorem ipsum dolor sit amet consectetur, adipisicing elit. Obcaecati ad fugit similique. Commodi sapiente esse mollitia tempora provident rem ut. Magni, ad itaque quidem veniam tempore repudiandae rem quis velit?`,
        img: 'https://storage.360buyimg.com/imgtools/e067cd5b69-07c864c0-dd02-11ed-8b2c-d7f58b17086a.png',
        price: price,
        checked: false,
        num: 1,
        otherData: data
    }
}

let mixData = () => {
    let str = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    let len = str.length
    let res = ''
    for (let i = 0; i < 1024 * 100; i++) {
        res += Math.floor(Math.random() * len)
    }
    return res
}

export const data = [1,2,3,4]